
import 'package:flutter/foundation.dart';

const sqlitedbVersion = 5; // app sqlite db version
const releaseSqlitedbName = 'umw.db'; // 这个在正式上线后绝不能修改 // umw
const testSqlitedbName = 'testumw005.db';
// 远程的版本，用于更新
const testRemoteVersion = "https://api.umwallet.cc/static/appinfo.json";
const testUri = "https://api.umwallet.cc";
const releaseUri = "https://api.umwallet.cc";
const releaseRemoteVersion = "https://api.umwallet.cc/static/appinfo.json";
const releaseRemoteConfig = "https://api.umwallet.cc/static/appconfig.json"; // 暂未使用
// 是否从商店更新
const upgradeByStore = 1;
const releaseBuild = true;
const accessCN = false; // 限制cn访问,远端也有控制
const appleID = "6468921385";

const walletconnetProjectId = '83d941c8db2e9e2f3fe74a358c9b3a93';

const releaseUMUri = "https://aws-wallet-1.metauton.com";
/*

// drn支付 第一步签名 地址
const DRNPayStep1ContractAddress = kReleaseMode ? '0xda34bDc898267493e4E8659df435E097c11f4Cb4' : '0x7665Ce0B53e7196227CAd0abE8C88724cF8A7617' ;

// drn支付 第二步签名 地址
const DRNPayStep2ContractAddress = kReleaseMode ?  '0xc99Ef6FA4213266b1c43d470150D575c4eF1A5Eb':'0x3C20B06118443efbC0580773f004750D86C13d36';
*/


// 防止测试把名称改掉的误操作
String getSqliteName() {
  if (kReleaseMode) {
    return releaseSqlitedbName;
  }
  return testSqlitedbName;
}

String getRemoteVersion() {
  if (kReleaseMode) {
    return releaseRemoteVersion;
  }
  return testRemoteVersion;
}

String getUri() {
  if (kReleaseMode) {
    return releaseUri;
  }
  return testUri;
}

String getUMUri() {
  return releaseUMUri;
}

// 是否存在测试币,发行模式不显示
bool showTestChain = kReleaseMode ? false : true;

Map<String, String> langmap = {
  'en_US': 'English',
  'zh_CN': '繁体中文',
};

enum PinType {
  create, // 创建
  chk, // 验证
  cancel, // 取消
  set, // 设置
  up, //更新
}

const NotfoundIndex = -1;

const String InfoBoot = 'um';

// 验证方式 0 未知 1，直接跳到home页面 2pin验证，3 指纹或者脸部识别
enum InfoAuthStatusEnum {
  unknown,
  home,
  pin,
  biometrics,
}

// 钱包来源 0未知1 初始化 2创建 3 导入
enum WalletSource { unknown, init, create, import }

//支持的币种symbol
// enum SupportNetworkSymbols { btc, btct, ltc, ltct, doge, doget, eth, etc, bsc, trx, trxt, goerli, apt, aptt, sui, suit, suid }

// 钱包模式，写进sqlite
enum WalletModeEnum {
  notfound,
  createWallet,
  importPhrase,
  imPrikey,
  watch,
}

List<String> AddressPath = ['bip44', 'bip44', 'bip49', 'bip84', 'bip86'];
List<String> ShowAddressPath = [
  "msg_acc_legacy",
  "msg_acc_legacy",
  "msg_acc_nested_segwit",
  "msg_acc_native_segwit",
  'msg_acc_p2tr',
];

Map<String, String> receiceChainTitle = {
  'eth': 'ETH/ERC20',
  'trx': 'TRX/TRC20',
  'bsc': 'BSC/BEP20',
  // 'goerli': 'ETH/ERC20',
  // 'trxt': 'TRX/TRC20',
  // 'bsct': 'BSC/BEP20',
};

List<String> WalletModeList = ['state_notfound', 'state_createWallet', 'state_importPhrase', 'state_imPrikey', 'state_watch'];
// 交易状态
List<String> TransactionStatus = ["state_notfound", "state_success", "state_pedding", "state_fail"];

Map<String, String> BIP32DerivationPath = {
  'btc-bip44': "m/44'/0'/0'/0/",
  'btc-bip49': "m/49'/0'/0'/0/",
  'btc-bip84': "m/84'/0'/0'/0/",
  'btc-bip86': "m/86'/0'/0'/0/",
  'btct-bip44': "m/44'/1'/0'/0/",
  'btct-bip49': "m/49'/1'/0'/0/",
  'btct-bip84': "m/84'/1'/0'/0/",
  'btct-bip86': "m/86'/1'/0'/0/",
  'eth-bip44': "m/44'/60'/0'/0/",
  'bsc-bip44': "m/44'/60'/0'/0/",
  'goerli-bip44': "m/44'/60'/0'/0/",
  'etc-bip44': "m/44'/61'/0'/0/",
  'doge-bip44': "m/44'/3'/0'/0/",
  'doget-bip44': "m/44'/1'/0'/0/",
  'ltc-bip44': "m/44'/2'/0'/0/",
  'ltc-bip49': "m/49'/2'/0'/0/",
  'ltc-bip84': "m/84'/2'/0'/0/",
  'ltc-bip86': "m/86'/2'/0'/0/",
  'ltct-bip44': "m/44'/1'/0'/0/",
  'ltct-bip49': "m/49'/1'/0'/0/",
  'ltct-bip84': "m/84'/1'/0'/0/",
  'ltct-bip86': "m/86'/1'/0'/0/",
  'trx-bip44': "m/44'/195'/0'/0/",
  'trxt-bip44': "m/44'/195'/0'/0/",
  'apt-bip44': "m/44'/637'/0'/0/",
  'aptt-bip44': "m/44'/637'/0'/0/",
  'sui-bip44': "m/44'/784'/0'/0/",
  'suit-bip44': "m/44'/784'/0'/0/",
  'suid-bip44': "m/44'/784'/0'/0/",
  'clv-bip44': "m/44'/60'/0'/0/",
  'utn-bip44': "m/44'/60'/0'/0/",
};

/**
 * 獲取支持USDT的網絡信息
 */
Map<String, Map<String, dynamic>> getUsdtNetMap() {
  return kReleaseMode ? {
    '137': { 'step1ContractAddress': '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', 'step2ContractAddress': '0x793A91ACA2A5A0F250E92A1289Fc4f2F1951B7e5', 'chainId': 137, 'decimal': 6, 'name': 'Polygon', 'flag': false, 'isShow': true, 'URL':'https://www.oklink.com/cn/polygon/tx/','address':'0xc2132D05D31c914a87C6611C10748AEb04B58e8F' ,'symbol': 'USDT' },
    '56': { 'step1ContractAddress': '0x55d398326f99059fF775485246999027B3197955', 'step2ContractAddress': '0x793A91ACA2A5A0F250E92A1289Fc4f2F1951B7e5', 'chainId': 56, 'decimal': 18, 'name': 'BNB Smart Chain', 'flag': false, 'isShow': true, 'URL':'https://bscscan.com/tx/','address':'0x55d398326f99059fF775485246999027B3197955' ,'symbol': 'USDT'},
    '42161': { 'step1ContractAddress': '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', 'step2ContractAddress': '0x793A91ACA2A5A0F250E92A1289Fc4f2F1951B7e5', 'chainId': 42161, 'decimal': 6, 'name': 'Arbitrum', 'flag': false, 'isShow': true, 'URL':'https://arbiscan.io/tx/','address':'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9' ,'symbol': 'USDT' },
    '9999': { 'step1ContractAddress': '', 'step2ContractAddress': '0xda34bDc898267493e4E8659df435E097c11f4Cb4', 'chainId': 9999, 'decimal': 6, 'name': 'UTON', 'flag': false, 'isShow': true, 'URL':'https://scanuton.umcrypto.io/tx/','address':'0xda34bDc898267493e4E8659df435E097c11f4Cb4'  ,'symbol': 'DRN'}
  } : {
    '8888': { 'step1ContractAddress': '', 'step2ContractAddress': '0xda34bDc898267493e4E8659df435E097c11f4Cb4', 'chainId': 8888, 'decimal': 6, 'name': 'clovetest', 'flag': false, 'isShow': true, 'URL':'http://47.103.192.221:14000/tx/','address':'0x7665Ce0B53e7196227CAd0abE8C88724cF8A7617' ,'symbol': 'DRN' },
    '11155111': { 'step1ContractAddress': '0xD86bd803E2A0a9339fE17D067FB5D95679E2Cc1d', 'step2ContractAddress': '0x0Dd071d6E3107e3399D74f03aE67B6EA6036d802', 'chainId': 11155111, 'decimal': 6, 'name': 'SepoliaETH', 'flag': false, 'isShow': true, 'URL':'https://sepolia.etherscan.io/tx/','address':'0xD86bd803E2A0a9339fE17D067FB5D95679E2Cc1d' ,'symbol': 'HSDT'},
    '56': { 'step1ContractAddress': '0x55d398326f99059fF775485246999027B3197955', 'step2ContractAddress': '0x793A91ACA2A5A0F250E92A1289Fc4f2F1951B7e5', 'chainId': 56, 'decimal': 18, 'name': 'BNB Smart Chain', 'flag': false, 'isShow': true, 'URL':'https://bscscan.com/tx/','address':'' ,'symbol': 'USDT' },
    '97':{'step1ContractAddress': '0xD86bd803E2A0a9339fE17D067FB5D95679E2Cc1d', 'step2ContractAddress': '0x0Dd071d6E3107e3399D74f03aE67B6EA6036d802', 'chainId': 97, 'decimal': 18, 'name': 'BNB Test', 'flag': false, 'isShow': true, 'URL':'https://testnet.bscscan.com/tx/','address':'0xD86bd803E2A0a9339fE17D067FB5D95679E2Cc1d' ,'symbol': 'USDT'}
  };
}

Map<String, dynamic> getUsdtData(String id) {
  var contractMap = getUsdtNetMap();
  return contractMap[id] ?? {};
}

String getBIP32DerivationPath(String network, int addrType) {
  return BIP32DerivationPath["${network.toLowerCase()}-${AddressPath[addrType]}"] ?? "";
}

String getBIP32DerivationPathFull(String network, int addrType, int i) {
  var s = BIP32DerivationPath["${network.toLowerCase()}-${AddressPath[addrType]}"] ?? "";
  if (s == '') {
    return s;
  }
  return s + i.toString();
}

//获取市场合约地址1-DRN 地址
String getDRNPayStep1ContractAddress() {
  if (kReleaseMode) {
    return '0xda34bDc898267493e4E8659df435E097c11f4Cb4';
  }
  return '0x7665Ce0B53e7196227CAd0abE8C88724cF8A7617';
}

//获取市场合约地址2 - 交易市场合约地址Marketplace:
String getDRNPayStep2ContractAddress() {
  if (kReleaseMode) {
    return '0xc99Ef6FA4213266b1c43d470150D575c4eF1A5Eb';
  }
  return '0x3C20B06118443efbC0580773f004750D86C13d36';
}

//nft 合约地址-NFT 地址
String getMarketPlaceContractAddress() {
  if (kReleaseMode) {
    return '0xAde7161C8A80583ae008964779bDba8090436c45';
  }
  return '0xeE400521aA99C569a0b9bB0862Da38420B07f670';
}

//获取市场合约链id
String getDRNPayStep2ContractChainId() {
  if (kReleaseMode) {
    return '9999';
  }
  return '8888';
}

String getHtmlAddress(){
  // return kReleaseMode ? "https://h5-club.umcrypto.io" : "https://120-union-h5.utonmos.com";
  return kReleaseMode ? "https://h5-club.umcrypto.io" : "https://120-union-h5.utonmos.com";
}

String getGameCodeAddress(){
  // return kReleaseMode ? "https://h5-club.umcrypto.io" : "https://120-union-h5.utonmos.com";
  return kReleaseMode ? "https://club.umcrypto.io/md/api/app" : "https://120-union-h5.utonmos.com/md/api/app";//
}

String getMarkH5KLine(){
  return kReleaseMode?"https://www.fidumart.com/?lang=":"http://192.168.2.34:5173?lang=";
}
